package com.oocl.o2o.client.service.impl;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.oocl.o2o.client.dao.OrderInfoDao;
import com.oocl.o2o.client.service.ComplaintInfoService;
import com.oocl.o2o.client.vo.ComplaintVO;
import com.oocl.o2o.connectutil.dto.ComplaintDTO;
import com.oocl.o2o.connectutil.util.ComplaintInfoForCUtil;

@Service(value="complaintInfoServiceImpl")
public class ComplaintInfoServiceImpl implements ComplaintInfoService {

	@Resource
	private OrderInfoDao orderInfoDao;

	@Transactional
	@Override
	public ComplaintVO add(ComplaintVO complaintVO) {
		try {
			ComplaintDTO complaintDTO = new ComplaintDTO();
			complaintDTO.setMerchantName(complaintVO.getMerchantName());
			complaintDTO.setReason(complaintVO.getReason());
			if(ComplaintInfoForCUtil.send(complaintDTO)){
				orderInfoDao.updateStatusById(complaintVO.getOrderInfoId());
				return complaintVO;
			}
		} catch (Exception e) {
			//如果没有发出去，返回给前端用户，提示发送失败！
			e.printStackTrace();
			return null;
		}
		return null;
	}

}
